home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / include / x11 / xcmsint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  7.2 KB  |  248 lines

  1. /* $XConsortium: Xcmsint.h,v 1.17 91/11/05 11:06:51 rws Exp $ */
  2.  
  3. /*
  4.  * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
  5.  *     All Rights Reserved
  6.  * 
  7.  * This file is a component of an X Window System-specific implementation
  8.  * of Xcms based on the TekColor Color Management System.  Permission is
  9.  * hereby granted to use, copy, modify, sell, and otherwise distribute this
  10.  * software and its documentation for any purpose and without fee, provided
  11.  * that this copyright, permission, and disclaimer notice is reproduced in
  12.  * all copies of this software and in supporting documentation.  TekColor
  13.  * is a trademark of Tektronix, Inc.
  14.  * 
  15.  * Tektronix makes no representation about the suitability of this software
  16.  * for any purpose.  It is provided "as is" and with all faults.
  17.  * 
  18.  * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
  19.  * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  20.  * PARTICULAR PURPOSE.  IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
  21.  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  22.  * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
  23.  * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  24.  * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
  25.  *
  26.  *
  27.  *    DESCRIPTION
  28.  *        Private include file for Color Management System.
  29.  *        (i.e., for API internal use only)
  30.  *
  31.  */
  32. #ifndef _XCMSINT_H_
  33. #define _XCMSINT_H_
  34.  
  35. #include <X11/Xcms.h>
  36.  
  37. /*
  38.  *    DEFINES
  39.  */
  40.  
  41.     /*
  42.      * Private Status Value
  43.      */
  44. #define    _XCMS_NEWNAME    -1
  45.  
  46.     /*
  47.      * Color Space ID's are of XcmsColorFormat type, which is an
  48.      *    unsigned short (16 bits).  
  49.      *
  50.      *    bit 15 (most significant bit):
  51.      *        0 == Device-Independent
  52.      *        1 == Device-Dependent
  53.      *
  54.      *    bit 14:
  55.          *          0 == Registered with X Consortium
  56.          *          1 == Unregistered
  57.          */
  58. #define       XCMS_DD_ID(id)          ((id) & (XcmsColorFormat)0x80000000)
  59. #define       XCMS_DI_ID(id)          (!((id) & (XcmsColorFormat)0x80000000))
  60. #define       XCMS_UNREG_ID(id)       ((id) & (XcmsColorFormat)0x40000000)
  61. #define       XCMS_REG_ID(id)         (!((id) & (XcmsColorFormat)0x40000000))
  62. #define       XCMS_FIRST_REG_DI_ID    (XcmsColorFormat)0x00000001
  63. #define       XCMS_FIRST_UNREG_DI_ID  (XcmsColorFormat)0x40000000
  64. #define       XCMS_FIRST_REG_DD_ID    (XcmsColorFormat)0x80000000
  65. #define       XCMS_FIRST_UNREG_DD_ID  (XcmsColorFormat)0xc0000000
  66.  
  67. /*
  68.  *    TYPEDEFS
  69.  */
  70.  
  71.     /*
  72.      * Structure for caching Colormap info.
  73.      *    This is provided for the Xlib modifications to:
  74.      *        XAllocNamedColor()
  75.      *        XLookupColor()
  76.      *        XParseColor()
  77.      *        XStoreNamedColor()
  78.      */
  79. typedef struct _XcmsCmapRec {
  80.     Colormap cmapID;
  81.     Display *dpy;
  82.     Window windowID;
  83.     Visual *visual;
  84.     struct _XcmsCCC *ccc;
  85.     struct _XcmsCmapRec *pNext;
  86. } XcmsCmapRec;
  87.  
  88.     /*
  89.      * Intensity Record (i.e., value / intensity tuple)
  90.      */
  91. typedef struct _IntensityRec {
  92.     unsigned short value;
  93.     XcmsFloat intensity;
  94. } IntensityRec;
  95.  
  96.     /*
  97.      * Intensity Table
  98.      */
  99. typedef struct _IntensityTbl {
  100.     IntensityRec *pBase;
  101.     unsigned int nEntries;
  102. } IntensityTbl;
  103.  
  104.     /*
  105.      * Structure for storing per-Visual Intensity Tables (aka gamma maps).
  106.      */
  107. typedef struct _XcmsIntensityMap {
  108.     VisualID visualID;
  109.     XPointer    screenData;    /* pointer to corresponding Screen Color*/
  110.                 /*    Characterization Data        */
  111.     void (*pFreeScreenData)();    /* Function that frees a Screen        */
  112.                 /*   structure.                */
  113.     struct _XcmsIntensityMap *pNext;
  114. } XcmsIntensityMap;
  115.  
  116.  
  117.     /*
  118.      * Structure for storing "registered" color space prefix/ID
  119.      */
  120. typedef struct _XcmsRegColorSpaceEntry {
  121.     char *prefix;    /* Color Space prefix (e.g., "CIEXYZ:") */
  122.     XcmsColorFormat id;    /* Color Space ID (e.g., XcmsCIEXYZFormat) */
  123. } XcmsRegColorSpaceEntry;
  124.  
  125.  
  126.     /*
  127.      * Xcms Per Display (i.e. connection) related data
  128.      */
  129. typedef struct _XcmsPerDpyInfo {
  130.  
  131.     XcmsCCC paDefaultCCC; /* based on default visual of screen */
  132.         /*
  133.          * Pointer to an array of XcmsCCC structures, one for
  134.          * each screen.
  135.          */
  136.     XcmsCmapRec *pClientCmaps;    /* Pointer to linked list of XcmsCmapRec's */
  137.  
  138. } XcmsPerDpyInfo, *XcmsPerDpyInfoPtr;
  139.  
  140. /*
  141.  *    DEFINES
  142.  */
  143.  
  144. #define XDCCC_NUMBER    0x8000000L    /* 2**27 per XDCCC */
  145.  
  146. #ifdef GRAY
  147. #define XDCCC_SCREENWHITEPT_ATOM_NAME    "XDCCC_GRAY_SCREENWHITEPOINT"
  148. #define XDCCC_GRAY_CORRECT_ATOM_NAME    "XDCCC_GRAY_CORRECTION"
  149. #endif /* GRAY */
  150.  
  151. #ifndef _ConversionValues
  152. typedef struct _ConversionValues {
  153.     IntensityTbl IntensityTbl;
  154. } ConversionValues;
  155. #endif
  156.  
  157. #ifdef GRAY
  158. typedef struct {
  159.     IntensityTbl *IntensityTbl;
  160. } GRAY_SCCData;
  161. #endif /* GRAY */
  162.  
  163. /*
  164.  *    DEFINES
  165.  */
  166.  
  167. #define XDCCC_MATRIX_ATOM_NAME    "XDCCC_LINEAR_RGB_MATRICES"
  168. #define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION"
  169.  
  170. typedef struct {
  171.     XcmsFloat XYZtoRGBmatrix[3][3];
  172.     XcmsFloat RGBtoXYZmatrix[3][3];
  173.     IntensityTbl *pRedTbl;
  174.     IntensityTbl *pGreenTbl;
  175.     IntensityTbl *pBlueTbl;
  176. } LINEAR_RGB_SCCData;
  177.  
  178. /*
  179.  *    DESCRIPTION
  180.  *        Include file for defining the math macros used in the
  181.  *        XCMS source.  Instead of using math library routines
  182.  *        directly, XCMS uses macros so that based on the
  183.  *        definitions here, vendors and sites can specify exactly
  184.  *        what routine will be called (those from libm.a or their
  185.  *        custom routines).  If not defined to math library routines
  186.  *        (e.g., sqrt in libm.a), then the client is not forced to
  187.  *        be linked with -lm.
  188.  */
  189.  
  190. #define XCMS_ATAN(x)        _XcmsArcTangent(x)
  191. #define XCMS_COS(x)        _XcmsCosine(x)
  192. #define XCMS_CUBEROOT(x)    _XcmsCubeRoot(x)
  193. #define XCMS_FABS(x)        ((x) < 0.0 ? -(x) : (x))
  194. #define XCMS_SIN(x)        _XcmsSine(x)
  195. #define XCMS_SQRT(x)        _XcmsSquareRoot(x)
  196. #define XCMS_TAN(x)        (XCMS_SIN(x) / XCMS_COS(x))
  197.  
  198. #if __STDC__
  199. double _XcmsArcTangent(double a);
  200. double _XcmsCosine(double a);
  201. double _XcmsCubeRoot(double a);
  202. double _XcmsSine(double a);
  203. double _XcmsSquareRoot(double a);
  204. #else
  205. double _XcmsArcTangent();
  206. double _XcmsCosine();
  207. double _XcmsCubeRoot();
  208. double _XcmsSine();
  209. double _XcmsSquareRoot();
  210. #endif
  211.  
  212. /*
  213.  *  DEFINES FOR GAMUT COMPRESSION AND QUERY ROUTINES
  214.  */
  215. #ifndef PI
  216. #  ifdef M_PI
  217. #    define PI M_PI
  218. #  else
  219. #    define PI 3.14159265358979323846264338327950
  220. #  endif /* M_PI */
  221. #endif /* PI */
  222. #ifndef degrees
  223. #  define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
  224. #endif /* degrees */
  225. #ifndef radians
  226. #  define radians(d) ((XcmsFloat)(d) * PI / 180.0)
  227. #endif /* radians */
  228.  
  229. #define XCMS_CIEUSTAROFHUE(h,c)    \
  230. ((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
  231. ((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \
  232. (XcmsFloat)1.0)))
  233. #define XCMS_CIEVSTAROFHUE(h,c)    \
  234. ((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
  235. ((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \
  236. (XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0)))
  237. /* this hue is returned in radians */
  238. #define XCMS_CIELUV_PMETRIC_HUE(u,v)    \
  239. (((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2)))
  240. #define XCMS_CIELUV_PMETRIC_CHROMA(u,v)    XCMS_SQRT(((u)*(u)) + ((v)*(v)))
  241.  
  242. #define XCMS_CIEASTAROFHUE(h,c)        XCMS_CIEUSTAROFHUE((h), (c))
  243. #define XCMS_CIEBSTAROFHUE(h,c)        XCMS_CIEVSTAROFHUE((h), (c))
  244. #define XCMS_CIELAB_PMETRIC_HUE(a,b)    XCMS_CIELUV_PMETRIC_HUE((a), (b))
  245. #define XCMS_CIELAB_PMETRIC_CHROMA(a,b)    XCMS_CIELUV_PMETRIC_CHROMA((a), (b))
  246.  
  247. #endif /* _XCMSINT_H_ */
  248.